<template>
  <div class="app-container">
    <el-row class="crud-header">
      <el-button
        type="primary"
        @click="createProduct(null)"
      >添加商品</el-button>
    </el-row>
    <br>
    <gridview
      ref="gridView"
      :api-service="apiService"
      :grid-config="configData.gridConfig"
      :grid-handles="configData.gridHandles"
      :grid-data="testData"
      :filter-config="configData.filterConfig"
      :grid-edit-width="300"
      :is-async="true"
      @action="onAction"
    />
  </div>
</template>

<script>
import Gridview from '@/components/Gridview'
import GridApiService from '@/api/grid'

export default {
  name: 'UserList',
  components: {
    Gridview
  },
  data() {
    return {
      testData: [],
      configData: [],
      apiService: new GridApiService('/shop/goods'),
      dialogFormVisible: false,
      dialogTitle: '编辑用户授权策略'
    }
  },
  created() {},
  mounted() {},
  methods: {
    createProduct() {
      this.$router.push({
        path: '/shop/create'
      })
    },
    getModel() {
      this.listLoading = true
      this.apiService.list(this.listQuery).then(response => {
        const { data } = response
        this.list = data.items
        this.total = data.meta.totalCount
        this.listLoading = false
      })
    },
    download(row) {
      console.log('点击了下载按钮', row)
    },
    assign(row) {
      console.log('点击了下载按钮', row)
      this.$refs.dialogForm.getModel(row.id)
      this.$refs.dialogForm.showDialog()
    },
    // 模态框数据提交
    dialogSubmit(data) {
      this.$refs.gridView.refresh()
      this.$message.success(this.dialogTitle + '成功！')
    }
  }
}
</script>
